1 @import 'mediawiki.mixins';
2 @import 'mediawiki.ui/variables';
6 // Styling checkboxes in a way that works cross browser is a tricky problem to solve.
7 // In MediaWiki UI put a checkbox and label inside a mw-ui-checkbox div.
8 // This renders in all browsers except IE 6-8 which do not support the `:checked` selector;
9 // these are kept backwards-compatible using the `:not( #noop )` selector.
10 // You should give the checkbox and label matching `id` and `for` attributes, respectively.
13 // <div class="mw-ui-checkbox">
14 // <input type="checkbox" id="kss-example-3">
15 // <label for="kss-example-3">Standard checkbox</label>
17 // <div class="mw-ui-checkbox">
18 // <input type="checkbox" id="kss-example-3-checked" checked>
19 // <label for="kss-example-3-checked">Standard checked checkbox</label>
21 // <div class="mw-ui-checkbox">
22 // <input type="checkbox" id="kss-example-3-disabled" disabled>
23 // <label for="kss-example-3-disabled">Disabled checkbox</label>
25 // <div class="mw-ui-checkbox">
26 // <input type="checkbox" id="kss-example-3-disabled-checked" disabled checked>
27 // <label for="kss-example-3-disabled-checked">Disabled checked checkbox</label>
32 display: inline-block;
33 line-height: @sizeInputBinary;
34 vertical-align: middle;
37 // We use the `:not` selector to cancel out styling on IE 8 and below
38 // Note: This may be broken on older Opera Mini devices.
39 .mw-ui-checkbox:not( #noop ) {
41 // Position relatively so we can make use of absolute pseudo elements
45 // Reset font sizes, see T74727
47 vertical-align: middle;
53 // Ensure the invisible input takes up the required `width` & `height`
54 width: @sizeInputBinary;
55 height: @sizeInputBinary;
56 // Support: Firefox mobile to override user-agent stylesheet, see T73750
59 // Hide `input[type=checkbox]` and instead style the label that follows
60 // Support: VoiceOver. Use `opacity` so that VoiceOver can still identify the checkbox
62 // Render *on top of* the label, so that it's still clickable, see T98905
70 // Pseudo `:before` element of the label after the checkbox now looks like a checkbox
73 background-color: #fff;
74 background-origin: border-box;
75 background-position: center center;
76 background-repeat: no-repeat;
77 .background-size( 0, 0 );
78 .box-sizing( border-box );
80 // Ensure alignment of checkbox to middle of the text in long labels, see T85241
83 width: @sizeInputBinary;
84 height: @sizeInputBinary;
85 margin-top: -( @sizeInputBinary / 2 );
86 border: 1px solid @colorGray7;
87 border-radius: @borderRadius;
90 // Apply a checkmark on the pseudo `:before` element when the input is checked
91 &:checked + label:before {
92 .background-image-svg( 'images/checkbox-checked.svg', 'images/checkbox-checked.png' );
93 .background-size( 90%, 90% );
105 .transition( ~'background-color 100ms, color 100ms, border-color 100ms, box-shadow 100ms' );
108 // `:focus` has to come first, otherwise a specificity race with `:hover:focus` etc is necessary
109 &:focus + label:before {
110 border-color: @colorProgressive;
111 box-shadow: @boxShadowWidgetFocus;
114 &:hover + label:before {
115 border-color: @colorProgressive;
118 &:active + label:before {
119 background-color: @colorProgressiveActive;
120 border-color: @borderColorInputBinaryActive;
121 box-shadow: @boxShadowInputBinaryActive;
126 background-color: @backgroundColorInputBinaryChecked;
127 border-color: @borderColorInputBinaryChecked;
130 &:focus + label:before {
131 background-color: @backgroundColorInputBinaryChecked;
132 border-color: @borderColorInputBinaryChecked;
133 box-shadow: @boxShadowProgressiveFocus;
136 &:hover + label:before {
137 background-color: @colorProgressiveHighlight;
138 border-color: @colorProgressiveHighlight;
141 &:active + label:before {
142 background-color: @backgroundColorInputBinaryActive;
143 border-color: @borderColorInputBinaryActive;
148 // disabled checkboxes have a gray background
149 &:disabled + label:before {
150 background-color: @colorGray12;
151 border-color: @colorGray12;